﻿using System;
using System.Linq;
using UtfprLibrary.Exceptions;

namespace UtfprLibrary.Helpers {
    /// <summary>
    /// A static helper class for string path.
    /// </summary>
    public static class PathHelper {
        /// <summary>
        /// TODO
        /// </summary>
        /// <exception cref="UtfprLibrary.Exceptions.UtfprHelpersException">Thrown when an exception occurs.</exception>
        public static string PathRemove(string path, int quantity) {
            try {
                string activePath = path;
                int lastIndex;
                int toEnd;
                for (int i = 0; i < quantity; i++) {
                    lastIndex = activePath.LastIndexOf("\\");
                    toEnd = activePath.Count();
                    activePath = activePath.Remove(lastIndex, toEnd - lastIndex);
                }
                return activePath;
            } catch (Exception ex) {
                throw new UtfprHelpersException(Properties.Resources.Helpers_PathHelper_ExMsg_PathRemove, ex);
            }
        }
    }
}
